package com.navinfo.platform.dataanalysis.dto;


import lombok.Data;
import org.apache.spark.sql.Column;

import java.io.Serializable;

/**
 * 单车辆基础统计信息表（周或月）
 *
 * @author wangshuai
 * @create 2018/11/27
 */
@Data
public class VehicleBaseStatisticsWeekOrMonth extends VehicleBaseStatisticsDay implements Serializable {

    /**
     * 一周的里程总和/7，单位：米
     * 一月的里程总和/当月天数，单位：米
     */
    private Integer avgMileage;

    /**
     * 平均运行时间，一周的运行时长总和/7，单位：秒
     * 平均运行时间，一月的运行时长总和/当月天数，单位：秒
     */
    private Integer avgWorkDuration;

    /**
     * 平均怠速时间，一周的怠速时长总和/7，单位：秒
     * 平均怠速时间，一月的怠速时长总和/当月天数，单位：秒
     */
    private Integer avgIdleDuration;


    /**
     * 列名转换
     * @return
     */
    public static Column[] monthColumns() {
        Column avgMileage = new Column("avgMileage").as("avg_mileage");
        Column avgWorkDuration = new Column("avgWorkDuration").as("avg_work_duration");
        Column avgIdleDuration = new Column("avgIdleDuration").as("avg_idle_duration");
        Column[] columns = new Column[]{avgMileage, avgWorkDuration, avgIdleDuration};
        Column[] dayColumns = columnsNotIncludeClock();
        Column[] monthColumns = new Column[dayColumns.length + columns.length];
        for (int x = 0; x < dayColumns.length; x++) {
            monthColumns[x] = dayColumns[x];
        }
        for (int y = 0; y < columns.length; y++) {
            monthColumns[dayColumns.length + y] = columns[y];
        }
        return monthColumns;
    }

}
